package com.sky.controller.admin;

import com.sky.annotation.ActionLog;
import com.sky.dto.BatchUpdateRequest;
import com.sky.dto.PageQuery;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.impl.NoteServiceImpl;
import com.sky.service.impl.ReviewServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminNoteController")
@Api(tags = "管理端-笔记的相关接口")
@Slf4j
@RequestMapping("/admin/note")
public class NoteController {
    @Autowired
    private NoteServiceImpl noteService;

    /**
     * 根据状态获取笔记
     */
    @GetMapping()
    @ApiOperation("根据状态获取笔记")
    public Result<PageResult> list(PageQuery pageQuery) {
        log.info("pageQuery:{}", pageQuery);
        PageResult result = noteService.list(pageQuery);
        return Result.success(result);
    }

    /**
     * 修改笔记状态
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/{id}/{status}")
    @ApiOperation("修改笔记状态")
    @ActionLog(value = "审核了笔记",module = "笔记管理模块")
    public Result update(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        noteService.update(id,status);
        return Result.success();
    }
    /**
     * 批量修改笔记状态
     * @param request
     * @return
     */
    @PutMapping("/batch-update")
    @ApiOperation("批量修改笔记状态")
    @ActionLog(value = "批量审核了笔记",module = "笔记管理模块")
    public Result batchUpdateStatus(@RequestBody BatchUpdateRequest request) {
        log.info("request:{}", request);
        noteService.batchUpdateStatus(request);
        return Result.success();
    }
}
